Add debugger support#118
Conversation
Braedon-Wooding-Displayr
left a comment
There was a problem hiding this comment.
Nothing major, but some cleanup + suggestions.
| cli::array<System::Byte>^ bytes = gcnew cli::array<System::Byte>((int)view.length()); | ||
| pin_ptr<System::Byte> pinned = &bytes[0]; | ||
| memcpy(pinned, view.characters8(), view.length()); | ||
| return System::Text::Encoding::UTF8->GetString(bytes); |
There was a problem hiding this comment.
We can just do a GetString(view.characters8) we might have to call the variant that takes in a byte* (and cast our uint8_t* -> byte*)
Saves a copy and is a lil cleaner for when we do v8 interop migration
| static std::string ManagedStringToUtf8(System::String^ str) | ||
| { | ||
| cli::array<System::Byte>^ bytes = System::Text::Encoding::UTF8->GetBytes(str); | ||
| std::string result(bytes->Length, '\0'); |
There was a problem hiding this comment.
Wouldn't this be bytes->Length + 1 since it needs to store the \0 or does std::string take it into account here for the ctor arg?
There was a problem hiding this comment.
It's the content length, not the buffer size, so this should be correct. The null terminator is handled internally.
| // V8 inspector 8-bit strings are UTF-8 encoded (CDP JSON is ASCII-safe) | ||
| cli::array<System::Byte>^ bytes = gcnew cli::array<System::Byte>((int)view.length()); | ||
| pin_ptr<System::Byte> pinned = &bytes[0]; | ||
| memcpy(pinned, view.characters8(), view.length()); |
There was a problem hiding this comment.
Does this view.length include \0 since we shouldn't copy that byte to C#
| { | ||
| std::unique_lock<std::mutex> lock(queueMutex); | ||
| cv.wait(lock, [this] { | ||
| return !pendingCommands.empty() || !waitingForDebugger.load(); |
There was a problem hiding this comment.
We don't check disconnecting here, but we check it below, I would guess that both would want to stop waiting once we are disconnecting.
Adds debugger support for debugging the V8 instance using the Chrome DevTools Protocol: